function [vsmo] = winfilt(x, wl, lpf, rate)

maxpts = length(x);
winl = maxpts/10;
w=hanning(winl*2);
w=w(1:length(w)/2); % just use half of it
yn = x;

yn(1:winl) = x(1:winl).*w';
n1 = length(yn) - winl + 1;
n2 = length(yn);
yn(n1:n2) = x(n1:n2).*fliplr(w');
wco = lpf/(0.5*1/(rate*0.000001)); % wco of 1 is for half of the sample rate, so set it like this...

if(wco > 0 & wco < 1 ) % verify cutoffs
    %     [b, a] = ellip(8, 0.01, 120, wco);   % elliptical filter
    %[b, a] = cheby1(8, 0.1, wco);  % filter used from 4/03 through 9/3/03
    %[b, a] = besself(8, wco); %
    [b, a] = butter(8, wco); % implemented 9/4/03.
    vsmo = filter(b, a, yn); % filter all the traces..
else
    vsmo = yn; % unfiltered version
    QueMessage('noise: Warning - no filter', 1);
end
vsmo(1:winl) = vsmo(1:winl).*w'; % reapply taper...
vsmo(n1:n2) = vsmo(n1:n2) .*fliplr(w');

